package com.xinshujia.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xinshujia.entity.DeviceEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * *************************************
 * *   @author: 野狼上校               **
 * *   @since: 2024-08-06 15:17       **
 * *   @version: 1.0                  **
 * *************************************
 * <p>
 *     设备持久化接口
 */
@Mapper
public interface DeviceDao extends BaseMapper<DeviceEntity> {
    /**
     * 根据角色id获取设备
     * @param roleId 角色id
     * @return 设备集合
     */
    @Select("SELECT d.* FROM auth_device d, auth_role_device ar WHERE ar.device_id = d.id AND ar.role_id = #{roleId};")
    Set<DeviceEntity> getDevicesByRoleId(@Param("roleId") Long roleId);
}
